package net.xiduth.game.player.quests;

import java.util.HashMap;
import java.util.Map;

import net.xiduth.Settings;
import net.xiduth.utils.Logger;

public class Quests {

	/**
	 * A map holding all quests.
	 */
	private static final Map<Object, Class<Quest>> quests = new HashMap<Object, Class<Quest>>(
			Settings.QUESTS);

	/**
	 * Get a quest.
	 * 
	 * @param quest
	 *            The quest.
	 * @return The quest instance.
	 */
	public static Quest getQuest(Object quest) {
		if (quest instanceof Quest) {
			return (Quest) quest;
		}
		Class<Quest> questClass = quests.get(quest);
		if (questClass == null) {
			return null;
		}
		try {
			return questClass.newInstance();
		} catch (Throwable e) {
			Logger.handle(e);
		}
		return null;
	}

	static {

	}

}
